import os.path

import xlrd

from config import BASE_PATH

"""
fileName:文件名
book_index：表格的行号 
sheet_name：表格的名字
"""
def read_excel(fileName,sheet_name,book_index=1):
    filepath=BASE_PATH+"\data\\"+fileName
    arr=[]
    with xlrd.open_workbook(filepath) as file:
       book= file.sheet_by_name(sheet_name)
       for a in range(book_index,book.nrows):
           arr.append(tuple(book.row_values(a)))
    return  arr

#获取单元格的值

def get_excel_cell(fileName,sheet_name,rowx=0, colx=1):
    filepath=os.path.dirname(os.path.dirname(__file__))+"\data\\"+fileName
    arr=[]
    with xlrd.open_workbook(filepath) as file:
       book= file.sheet_by_name(sheet_name)
       arr.append(book.cell(rowx,colx).value)
       return arr




